package droid.frame.view;

import android.content.Context;
import android.util.AttributeSet;

/**
 * 扩展SwipeRefreshLayout实现属性的可配置<br>
 *
 * @author coffee<br>
 *         2017-1-4下午4:21:18
 */
public class SwipeRefreshLayout extends android.support.v4.widget.SwipeRefreshLayout {

	public SwipeRefreshLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		setStyle(context);
	}
	@SuppressWarnings("ResourceType")
	private void setStyle(Context context) {
		// setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, //
		// android.R.color.holo_orange_light, android.R.color.holo_red_light);

		int colorResId = getResources().getIdentifier("app_swipe_color", "id", context.getPackageName());
		if (colorResId == 0) {
			colorResId = getResources().getIdentifier("app_theme_color", "id", context.getPackageName());
		}
		if (colorResId != 0) {
			int colorRes = getResources().getColor(colorResId);
			setColorSchemeResources(colorRes);
		}
		// setDistanceToTriggerSync(400);// 设置手指在屏幕下拉多少距离会触发下拉刷新
		// setProgressBackgroundColor(android.R.color.background_light); // 设定下拉圆圈的背景
		setSize(SwipeRefreshLayout.DEFAULT); // 设置圆圈的大小
	}

}
